package concurrent.chapter11_1;

public final class ActionContext {
    private static final ThreadLocal<Context> threadLocal=new ThreadLocal<>(){
        @Override
        protected Context initialValue() {
            return new Context();
        }
    };
    public Context getContext(){
        return threadLocal.get();
    }

    //用holder方式作一个单例模式
    private static class ContextHolder{
        private final static ActionContext adtionContext=new ActionContext();
    }
    public static ActionContext getActionContext(){
        return ContextHolder.adtionContext;
    }
}
